<include file="Public/header"/>
<include file="Public/menu"/>
<!-- 内容页 -->
<div class="content-wrapper">
    <!-- 面包屑 -->
    <section class="content-header">
        <h1>
            首页
            <small>采购</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="{:U('purchase/shoppingList')}"><i class="fa fa-dashboard"></i> 采购</a></li>
            <li class="active">已提交的采购单</li>
        </ol>
    </section>

    <!-- 内容 -->
    <section class="content">

        <div class="tab-content">
            <div class="tab-pane active" id="tab_0">
                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title">
                            <div class="btn-group pull-left" style="margin-right: 10px">
                                <a href="javascript:window.history.back();" class="btn btn-sm btn-default"><i class="fa fa-list"></i>&nbsp;返回列表</a>
                            </div>
                        </h3>
                        <div class="form-inline pull-right">
                            <form action="" method="get" pjax-container="">
                                <fieldset>
                                    <select class="form-control" name="search_field" style="height: 30px; font-size: 12px;">
                                        <option value="name" <if condition="$search_field eq 'name'">selected="selected"</if>>货品名称</option>
                                        <option value="barcode" <if condition="$search_field eq 'barcode'">selected="selected"</if>>条码</option>
                                        <option value="bn" <if condition="$search_field eq 'bn'">selected="selected"</if>>BN</option>
                                    </select>
                                    <div class="input-group input-group-sm">
                                        <div class="input-group input-group-sm">
                                            <input type="text" class="form-control" placeholder="" name="search" value="{$search}">
                                        </div>
                                    </div>

                                    <div class="input-group input-group-sm">
                                        <div class="input-group-btn">
                                            <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i>
                                            </button>
                                        </div>
                                    </div>
                                </fieldset>
                            </form>
                        </div>

                    </div>
                    <!-- /.box-header -->
                    <div class="box-body table-responsive no-padding">
                        <table class="table table-hover table-view-list">
                            <tbody>
                            <tr>
                                <th><!--<input type="checkbox" class="grid-select-all">--></th>
                                <th>货品ID<a class="fa fa-fw fa-sort" href="{:U('purchase/products',array('purc_id'=>$purc_id,'p'=>$p,'order_field'=>'product_id','order'=>$order), '')}"></a></th>
                                <th>货品名称</th>
                                <th>货品描述</th>
                                <th>图片</th>
                                <th>商品ID</th>
                                <th>条码</th>
                                <th>BN</th>
                                <th>采购价格</th>
                                <th>采购数量</th>
                            </tr>
                            <volist name="list" id="vo">
                                <tr class="cg-product-tr">
                                    <td><!--<input type="checkbox" class="grid-item" data-id="{$vo.product_id}">--></td>
                                    <td>{$vo.product_id}</td>
                                    <td><a href="javascript:;" class="short-gname" title="{$vo.name}">{$vo.name}</a></td>
                                    <td>{$vo.spec_info}</td>
                                    <td><img src="{$vo.goods_id|getThumb=###}" data-bimg="{$vo.goods_id|getThumb=###}" alt="" class="scale-img" /></td>
                                    <td>{$vo.goods_id}</td>
                                    <td>{$vo.barcode}</td>
                                    <td>{$vo.bn}</td>
                                    <td>{$vo.purc_price}</td>
                                    <td>{$vo.purc_sum}</td>
                                </tr>
                            </volist>
                            </tbody>
                        </table>
                    </div>
                    <div class="box-footer clearfix">
                        <!--<input type="checkbox" class="grid-select-all">-->&nbsp;&nbsp;&nbsp;
                        <!--<a class="btn btn-sm btn-info batch-info">保存采购单</a>-->
                        <a class="btn btn-sm btn-primary grid-refresh"><i class="fa fa-refresh"></i></a>
                        {$page}
                    </div>
                    <!-- /.box-body -->
                </div>
            </div>

        </div>
    </section>
</div>
<!-- 底部 -->
<include file="Public/common_footer"/>
<script src="/Public/layer/layer.js"></script>
<script type="text/javascript">
    $(function () {
        $('.grid-select-all').change(function () {
            if (this.checked) {
                $('.grid-item').prop("checked", true);
            } else {
                $('.grid-item').prop("checked", false);
            }
        });
        $('._delete').click(function () {
            if(!confirm("确认删除")){
                return false;
            }
            var vendor_id = $(this).attr('data-id');
            if (vendor_id) {
                $.ajax({
                    type: "POST",
                    url: "{:U('vendor/del')}",
                    data: {vendor_id:vendor_id},
                    success: function(msg){
                        alert(msg.message);
                        window.location.reload();
                    },
                    error: function (msg) {
                        alert(msg.message);
                    }
                });
            }
        });

        $('.batch-delete').on('click',function(e){
            if(!confirm("确认批量删除")){
                return false;
            }
            var data = [];
            $(".grid-item[type='checkbox']:checked").each(function (i) {
                var vendor_id = $(this).attr('data-id');
                data.push(vendor_id);
                $(this).parent().parent().remove();
            });
            if (data) {
                $.ajax({
                    type: "POST",
                    url: "{:U('vendor/del')}",
                    data: {vendor_id:data},
                    success: function(msg){
                        alert(msg.message);
						window.location.reload();
                    },
                    error: function (msg) {
                        alert(msg.message);
                    }
                });
            }
        })
		showBigPicture();
    });
</script>